﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using NUnitResults;

namespace NUnitResultsTests.Resources
{
    /// <summary>
    /// Provides methods which generate test cases which are
    /// used by multiple test fixtures.
    /// </summary>
    internal static class TestCases
    {
        /// <summary>
        /// Gets all the possible Statusses.
        /// </summary>
        /// <returns></returns>
        internal static IEnumerable<Status> GetSampleStatusses()
        {
            var enums = Enum.GetValues(typeof(Status));

            for (int i = 0; i < enums.Length; i++)
            {
                yield return (Status)enums.GetValue(i);
            }
        }

        /// <summary>
        /// Gets sample results files and their representation in ITestResults.
        /// </summary>
        /// <returns></returns>
        internal static IEnumerable<TestCaseData> GetSampleResults()
        {
            yield return new TestCaseData(
                "Sample01.xml",
                12,
                Status.Success,
                new List<ITestResult>()
                {
                    new TestSuite(@"C:\Documents and Settings\a_humphrey\My Documents\Visual Studio 2008\Projects\NUnitResultsExplorer\NUnitResultsTests\bin\Debug\NUnitResultsTests.dll", String.Empty, Status.Success, SuiteType.Assembly, TimeSpan.FromSeconds(0.094), 0, new List<ITestResult>()
                    {
                        new TestSuite("NUnitResultsTests", String.Empty, Status.Success, SuiteType.Namespace, TimeSpan.FromSeconds(0.094), 0, new List<ITestResult>()
                        {
                            new TestSuite("Integration", "NUnitResultsTests", Status.Success, SuiteType.Namespace, TimeSpan.FromSeconds(0.047), 0, new List<ITestResult>()
                            {
                                new TestSuite("ResultFileTests", "NUnitResultsTests.Integration", Status.Success, SuiteType.TestFixture, TimeSpan.FromSeconds(0.047), 0, new List<ITestResult>()
                                {
                                    new TestCase("TestReadFile", "NUnitResultsTests.Integration.ResultFileTests", Status.Success, TimeSpan.FromSeconds(0.047), 1)
                                })
                            }),
                            new TestSuite("Unit", "NUnitResultsTests", Status.Success, SuiteType.Namespace, TimeSpan.FromSeconds(0.047), 0, new List<ITestResult>()
                            {
                                new TestSuite("TestSuiteTests", "NUnitResultsTests.Unit", Status.Success, SuiteType.TestFixture, TimeSpan.FromSeconds(0.047), 0, new List<ITestResult>()
                                {
                                    new TestCase("TestEmptyTestSuiteStatus", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0.031), 1),
                                    new TestSuite("TestMultiResultTestSuiteStatus", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, SuiteType.ParameterizedTest, TimeSpan.FromSeconds(0), 0, new List<ITestResult>()
                                    {
                                        new TestCase("TestMultiResultTestSuiteStatus(Inconclusive)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestMultiResultTestSuiteStatus(Error)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestMultiResultTestSuiteStatus(Failed)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestMultiResultTestSuiteStatus(Ignored)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestMultiResultTestSuiteStatus(Success)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1)
                                    }),
                                    new TestSuite("TestSingleResultTestSuiteStatus", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, SuiteType.ParameterizedTest, TimeSpan.FromSeconds(0), 0, new List<ITestResult>()
                                    {
                                        new TestCase("TestSingleResultTestSuiteStatus(Inconclusive)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestSingleResultTestSuiteStatus(Error)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestSingleResultTestSuiteStatus(Failed)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestSingleResultTestSuiteStatus(Ignored)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1),
                                        new TestCase("TestSingleResultTestSuiteStatus(Success)", "NUnitResultsTests.Unit.TestSuiteTests", Status.Success, TimeSpan.FromSeconds(0), 1)
                                    })
                                })
                            })
                        })
                    })
                }
            );

            yield return new TestCaseData(
                "Sample02.xml",
                6,
                Status.Failed,
                new List<ITestResult>()
                {
                    new TestSuite(@"C:\Documents and Settings\a_humphrey\My Documents\Visual Studio 2008\Projects\GenericTests\GenericTests\bin\Debug\GenericTests.dll", String.Empty, Status.Failed, SuiteType.Assembly, TimeSpan.FromSeconds(0.094), 0, new List<ITestResult>()
                    {
                        new TestSuite("GenericTests", String.Empty, Status.Failed, SuiteType.Namespace, TimeSpan.FromSeconds(0.078), 0, new List<ITestResult>()
                        {
                            new TestSuite("Tests", "GenericTests", Status.Failed, SuiteType.TestFixture, TimeSpan.FromSeconds(0.078), 0, new List<ITestResult>()
                            {
                                new FailedTestCase("TestError", "GenericTests.Tests", Status.Error, TimeSpan.FromSeconds(0.016), 0, "System.Exception : Test errored!", "at GenericTests.Tests.TestError() in C:\\Documents and Settings\\a_humphrey\\My Documents\\Visual Studio 2008\\Projects\\GenericTests\\GenericTests\\Tests.cs:line 27\n"),
                                new FailedTestCase("TestFail", "GenericTests.Tests", Status.Failed, TimeSpan.FromSeconds(0.016), 0, "Test failed!", "at GenericTests.Tests.TestFail() in C:\\Documents and Settings\\a_humphrey\\My Documents\\Visual Studio 2008\\Projects\\GenericTests\\GenericTests\\Tests.cs:line 21\n"),
                                new NotRunTestCase("TestIgnored", "GenericTests.Tests", Status.Ignored, null, null, "Test ignored!"),
                                new TestSuite("TestInconclusive", "GenericTests.Tests", Status.Failed, SuiteType.Theory, TimeSpan.FromSeconds(0.016), 0, new List<ITestResult>()
                                {
                                    new NotRunTestCase("TestInconclusive(1.0d)", "GenericTests.Tests", Status.Inconclusive, TimeSpan.FromSeconds(0.016), 0, "  Expected: True\n  But was:  False\n")
                                }),
                                new NotRunTestCase("TestNotRunnable", "GenericTests.Tests", Status.NonRunnable, null, null, "No arguments were provided"),
                                new TestCase("TestSuccess", "GenericTests.Tests", Status.Success, TimeSpan.FromSeconds(0), 0)
                            })
                        })
                    })
                }
            );
        }
    }
}
